package com.core.request.bo;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.core.request.dao.VisaRequestDAO;
import com.core.request.pojo.VisaCancelDto;
import com.core.request.pojo.VisaForDownloadReturnReportDto;
import com.core.request.pojo.VisaForImportReturnReportDto;
import com.core.request.pojo.VisaResponse;
import com.util.Consts;
import com.core.request.pojo.VisaAddUpdateDtoSql;

@Service
public class VisaRequestBo {
	@Resource
	private VisaRequestDAO visaRequestDAO;

	// =========================visa==============================//
	public VisaAddUpdateDtoSql getVisaForAddUpdate() {
		VisaAddUpdateDtoSql visa = visaRequestDAO.getVisaForAddUpdate();
		return visa;
	}

	public VisaCancelDto getVisaForCancel() {
		VisaCancelDto dto = visaRequestDAO.getVisaForCancel();
		return dto;
	}

	public int updateVisaState(VisaResponse visaResponse) {
		visaResponse.setSubmitDate(new Date());
		return visaRequestDAO.updateVisaState(visaResponse);
	}

	// =========================return_report==============================//
	// --upload
	public VisaForImportReturnReportDto getVisaForImportReturnReport() {
		VisaForImportReturnReportDto dto = visaRequestDAO.getVisaForImportReturnReport();
		return dto;
	}

	public void updateReturnReportState(VisaResponse visaResponse) {
		visaResponse.setSubmitDate(new Date());
		visaRequestDAO.updateReturnReportState(visaResponse);
	}

	// --download.
	public VisaForDownloadReturnReportDto getVisaForDownloadReturnReport() {
		VisaForDownloadReturnReportDto dto = visaRequestDAO.getVisaForDownloadReturnReport();
		return dto;
	}

	public void updateReturnReportDownloadState(VisaResponse visaResponse) {
		if (Consts.RETURN_REPORT_DOWNLOAD_STATE_SUCC == visaResponse.getReturnReportDownloadState()) {
			visaResponse.setReturnReportPdfDownloadTime(new Date());
		}
		visaRequestDAO.updateReturnReportDownloadState(visaResponse);
	}

}
